package com.tianshi.yingxue.controller;

import com.tianshi.yingxue.entity.Admin;
import com.tianshi.yingxue.service.AdminService;
import com.tianshi.yingxue.utils.ImageCodeUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/admin")
public class AdminController {
    @Autowired
    private AdminService adminService;

    @RequestMapping("/getImageCode")
    public Map<String, String> getImageCodes() throws IOException {
        return adminService.getImageCodes();
    }
    @PostMapping("/login")
    public Map<String,String> login(@RequestBody Admin admin, String token){
        return adminService.login(admin,token);
    }
    @GetMapping("/getUserInfo")
    public Admin getUserInfo(String token){
        return adminService.getUserInfo(token);
    }

    @PostMapping("/logout")
    void logout(String token){
        System.out.println("=========================="+token);
        adminService.logout(token);
    }


}
